{extend name="main/index" /}
{block name="main"}
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="#">Home</a>
            </li>

            <li>
                <a href="#">Tables</a>
            </li>
            <li class="active">材料入库列表</li>
        </ul><!-- .breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
                    <i class="icon-search nav-search-icon"></i>
                </span>
            </form>
        </div><!-- #nav-search -->
    </div>

    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <div class="row">
                    <div class="col-xs-12">
                        <h3 class="header smaller lighter blue">项目材料入库</h3>
                        <div class="table-responsive">
                            <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                <thead>
                                    <tr>
                                            <th>ID</th>
                                            <th>用品名称</th>
                                            <th>供应商</th>
                                            <th>数量</th>
                                            <th>单价</th>
                                            <th>总价</th>
                                            <th>库存</th>
                                            <th>更改状态</th>
                                            
                                    </tr>
                                </thead>
                                <tbody>
                                {volist name="list" id="v"}
                                    <tr>
                                            <td>{$v['id']}</td>
                                            <td>{$v['supplies_name']}</td>
                                            <td>{$v['supplier']}</td>
                                            <td>{$v['number']}</td>
                                            <td>{$v['unit_price']}</td>
                                            <td>{$v['total_price']}</td>
                                            <td>{$v['inventory']}</td>
                                        <td>

                                            <!--<span class="label label-lg label-yellow arrowed-in">Yellow</span>-->
                                            <!--<button class="btn btn-info">Info</button>-->
                                            <!--<button class="btn btn-xs btn-danger">Danger</button>-->
                                            <a href="{:url('admin/office/getOffice',['id'=> $v['id']])}"><span class="label label-lg label-yellow arrowed-in">修改</span></a>
                                            <a href="{:url('admin/office/suppliesData',['id'=> $v['id']])}"><span class="label label-lg label-pink arrowed-right">增加</span></a>
                                            <a href="{:url('admin/office/outbound', ['id' => $v['id']])}"><span class="label label-lg label-yellow arrowed-in">出库</span></a>
                                            <button data-id="{$v['id']}"  class="btn btn-xs btn-danger del-btn" id="btn" >删除</button>
                                        </td>
                                    </tr>
                                {/volist}
                                </tbody>
                            </table>

                        </div>
                    </div>
                </div>
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
</div>
    {/block}

{block name="myjs"}
<script>
    $(function() {
        $('.del-btn').click(function(){
            var ac_id = $(this).attr('data-id');
            console.log(ac_id);

            if (confirm('你确定要 [ 删 除 ] 吗?')) {
                var obj = $(this).parents('tr');
                delAjax(ac_id, obj);
            }

        });
    });


    function delAjax(id,obj) {
        $.ajax({
            type: 'delete',
            url: '/admin/Material/delectOutWarehouse/id/'+id,
            dataType: 'json',
            success: function (data) {
               console.log(data);
                if (data.status) {
                    alert(1111);
                    obj.remove();
                } else {
                    alert(2222);
                }
            },
            error: function () {
                alert('AJAX执行失败');
            }
        });
    }
</script>

{/block}

